/*
 * Ray.h
 *
 *  Created on: May 12, 2012
 *      Author: walther
 */

#ifndef RAY_H_
#define RAY_H_

#include "Vector4D.h"

/**
 * Abstraction of a Ray as a line
 * P(t) = origin + t * direction
 */
//typedef struct t_ray
//{
//    /** Point where the ray starts */
//    Vector4D origin;
//    
//    /** Direction to which it goes. Must be normalized */
//    Vector4D direction;
//}Ray;

class Ray
{
public:
    /**
     * Constructor
     * @param memorySize
     */
    Ray( int memorySize = 0 );
    
    /**
     * Copy Constructor
     * @param copy
     */
    Ray( const Ray& copy );
    
    /**
     * Destructor
     */
    ~Ray();
    
    /**
     * Adds an object to the ray memory
     * @param objectID
     */
    void addToMemory( int objectID );
    
    /**
     * Tests if an object is in ray memory
     * @param objectID
     * @return true if in memory, false otherwise
     */
    bool isInMemory( int objectID );
    
    /** Point where the ray starts */
    Vector4D origin;
    
    /** Direction to which it goes. Must be normalized */
    Vector4D direction;
    
private:
    
    /** Number of objects that fit inside the memory */
    int _memorySize;
    
    /** Array of tested objects */
    int* _testedObjects;
    
    /** Last position in the array of tested objects */
    int _lastPosition;
};

#endif /* RAY_H_ */
